
package Individual;

import Loader.BufferedData;
import Settings.*;

public class Initialization {

    public static void initialization( Individual[] individuals,
                                       BufferedData bd ) {

        if( individuals == null || individuals.length == 0 )
            return;

        for(int i = 0; i < individuals.length; ++i) {

            int numOfCluster = Settings.CHROMOSOME_NUMBER_OF_CLUSTERS;
            int numOfFeatures = Settings.CHROMOSOME_NUMBER_OF_FEATURES;
            int numOfBitsPerVal = Settings.CHROMOSOME_NUMBER_OF_BITS_PER_VALUE;
            individuals[i] = new Individual( numOfCluster,
                                             numOfFeatures,
                                             numOfBitsPerVal,
                                             bd
                                           );

            for(int c = 0; c < individuals[i].numOfClusters; ++c)
                for(int f = 0; f < individuals[i].numOfFeatures; ++f)
                    for(int b = 0; b < individuals[i].numOfBitsPerValue; ++b) {

                        //boolean bit = ( (int)(Math.random() * 10) ) %2 == 0;
                        boolean bit = (b+1) / numOfBitsPerVal < 0.5;
                        individuals[i].chromosome.get(c).get(f).set(b, bit);

                    }

            individuals[i].computeCentroids();
        }
        
    }

}
